package com.mvc.business.model;

import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;

import com.mvc.ProjectUtils;
import com.mvc.base.model.BaseCompany;
import com.mvc.base.model.Customer;
import com.mvc.base.model.Picture;

/**
 */
@Entity(name = "B_ORDER")
public class Order extends BaseCompany {

	public static final int	  ORDER_STATUS_DICTIONARY_ID	     = 301;
	public static final int	  ORDER_FINANCE_STATUS_DICTIONARY_ID	= 302;

	public static final int	  ORDER_STATUS_DRAFT	             = 1;
	public static final int	  ORDER_STATUS_COMMIT	             = 10;
	public static final int	  ORDER_STATUS_APPROVED	             = 20;

	public static final int	  ORDER_STATUS_BACKWARD	             = 15;

	public static final int	  ORDER_STATUS_FINISHED	             = 50;

	public static final int	  ORDER_FINANCE_STATUS_UNPAY	     = 1;
	public static final int	  ORDER_FINANCE_STATUS_PAYED	     = 10;

	@NotNull
	private Date	          orderDate;
	@NotNull
	private Integer	          customerId;
	@NotNull
	private Integer	          salesId;
	/**
	 * 总计
	 */
	private Double	          total;

	private Double	          quantity;

	private Double	          freight;

	/**
	 * 订单状态
	 */
	@NotNull
	private Integer	          status;

	/**
	 * 财务状态
	 */
	@NotNull
	private Integer	          financeStatus;

	@Transient
	private List<OrderItem>	  orderItems;

	@Transient
	private List<OrderCharge>	charges;

	private Date	          sendDate;

	private Date	          receivedDate;

	private Date	          etdDate;
	// 预计付款日期
	private Date	          predictPayDate;

	private Date	          payDate;

	@Length(max = 64)
	private String	          salesCondition;
	@Length(max = 64)
	private String	          shipment;
	@Length(max = 64)
	private String	          payment;
	@Length(max = 64)
	private String	          clientPo;

	@Length(max = 4096)
	private String	          remark;
	@NotNull
	private Integer	          currency;

	private Integer	          appovalUserId;
	private Date	          auditDate;

	@Length(max = 64)
	private String	          backwardReason;

	@Transient
	private Customer	      customer;
	@Transient
	private List<Picture>	  pictures;

	/**
	 * @return the orderDate
	 */
	public Date getOrderDate() {
		return orderDate;
	}

	/**
	 * @param orderDate
	 *            the orderDate to set
	 */
	public void setOrderDate(Date orderDate) {
		this.orderDate = orderDate;
	}

	/**
	 * @return the customerId
	 */
	public Integer getCustomerId() {
		return customerId;
	}

	public String getCustomerNo() {
		return ProjectUtils.getCustomerNo(customerId);
	}

	/**
	 * @param customerId
	 *            the customerId to set
	 */
	public void setCustomerId(Integer customerId) {
		this.customerId = customerId;
	}

	/**
	 * @return the salesId
	 */
	public Integer getSalesId() {
		return salesId;
	}

	/**
	 * @param salesId
	 *            the salesId to set
	 */
	public void setSalesId(Integer salesId) {
		this.salesId = salesId;
	}

	/**
	 * @return the remark
	 */
	public String getRemark() {
		return remark;
	}

	/**
	 * @param remark
	 *            the remark to set
	 */
	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * @return the freight
	 */
	public Double getFreight() {
		return freight;
	}

	/**
	 * @param freight
	 *            the freight to set
	 */
	public void setFreight(Double freight) {
		this.freight = freight;
	}

	/**
	 * @return the status
	 */
	public Integer getStatus() {
		return status;
	}

	/**
	 * @param status
	 *            the status to set
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}

	/**
	 * @return the financeStatus
	 */
	public Integer getFinanceStatus() {
		return financeStatus;
	}

	/**
	 * @param financeStatus
	 *            the financeStatus to set
	 */
	public void setFinanceStatus(Integer financeStatus) {
		this.financeStatus = financeStatus;
	}

	/**
	 * @return the orderItems
	 */
	public List<OrderItem> getOrderItems() {
		return orderItems;
	}

	/**
	 * @param orderItems
	 *            the orderItems to set
	 */
	public void setOrderItems(List<OrderItem> orderItems) {
		this.orderItems = orderItems;
	}

	/**
	 * @return the sendDate
	 */
	public Date getSendDate() {
		return sendDate;
	}

	/**
	 * @param sendDate
	 *            the sendDate to set
	 */
	public void setSendDate(Date sendDate) {
		this.sendDate = sendDate;
	}

	/**
	 * @return the receivedDate
	 */
	public Date getReceivedDate() {
		return receivedDate;
	}

	/**
	 * @param receivedDate
	 *            the receivedDate to set
	 */
	public void setReceivedDate(Date receivedDate) {
		this.receivedDate = receivedDate;
	}

	/**
	 * @return the payDate
	 */
	public Date getPayDate() {
		return payDate;
	}

	/**
	 * @param payDate
	 *            the payDate to set
	 */
	public void setPayDate(Date payDate) {
		this.payDate = payDate;
	}

	/**
	 * @return the salesCondition
	 */
	public String getSalesCondition() {
		return salesCondition;
	}

	/**
	 * @param salesCondition
	 *            the salesCondition to set
	 */
	public void setSalesCondition(String salesCondition) {
		this.salesCondition = salesCondition;
	}

	/**
	 * @return the payment
	 */
	public String getPayment() {
		return payment;
	}

	/**
	 * @param payment
	 *            the payment to set
	 */
	public void setPayment(String payment) {
		this.payment = payment;
	}

	/**
	 * @return the clientPo
	 */
	public String getClientPo() {
		return clientPo;
	}

	/**
	 * @param clientPo
	 *            the clientPo to set
	 */
	public void setClientPo(String clientPo) {
		this.clientPo = clientPo;
	}

	/**
	 * @return the total
	 */
	public Double getTotal() {
		return total;
	}

	/**
	 * @param total
	 *            the total to set
	 */
	public void setTotal(Double total) {
		this.total = total;
	}

	/**
	 * @return the customer
	 */
	public Customer getCustomer() {
		return customer;
	}

	/**
	 * @param customer
	 *            the customer to set
	 */
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	/**
	 * @return the shipment
	 */
	public String getShipment() {
		return shipment;
	}

	/**
	 * @param shipment
	 *            the shipment to set
	 */
	public void setShipment(String shipment) {
		this.shipment = shipment;
	}

	public Integer getCurrency() {
		return currency;
	}

	public void setCurrency(Integer currency) {
		this.currency = currency;
	}

	public Integer getAppovalUserId() {
		return appovalUserId;
	}

	public void setAppovalUserId(Integer appovalUserId) {
		this.appovalUserId = appovalUserId;
	}

	public List<OrderCharge> getCharges() {
		return charges;
	}

	public void setCharges(List<OrderCharge> charges) {
		this.charges = charges;
	}

	public Date getEtdDate() {
		return etdDate;
	}

	public void setEtdDate(Date etdDate) {
		this.etdDate = etdDate;
	}

	public Date getPredictPayDate() {
		return predictPayDate;
	}

	public void setPredictPayDate(Date predictPayDate) {
		this.predictPayDate = predictPayDate;
	}

	public List<Picture> getPictures() {
		return pictures;
	}

	public void setPictures(List<Picture> pictures) {
		this.pictures = pictures;
	}

	/**
	 * @return the purchaseNo
	 */
	public String getOrderNo() {
		return ProjectUtils.getOrderNo(getObjectId());
	}

	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public String getBackwardReason() {
		return backwardReason;
	}

	public void setBackwardReason(String backwardReason) {
		this.backwardReason = backwardReason;
	}

	public Date getAuditDate() {
		return auditDate;
	}

	public void setAuditDate(Date auditDate) {
		this.auditDate = auditDate;
	}

}
